import { S } from '../s';
import { IPSEditor } from './ipseditor';
import { IPSEditorItem } from './ipseditor-item';
import { IPSNavigateContext } from './ipsnavigate-context';
import { IPSNavigateParam } from './ipsnavigate-param';
import { IPSNavigateParamContainer } from './ipsnavigate-param-container';
import { IPSSysCss } from '../res/ipssys-css';
import { IPSSysDictCat } from '../res/ipssys-dict-cat';
import { IPSSysPFPlugin } from '../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSEditorImpl
  extends PSModelObjectImpl
  implements IPSEditor, IPSNavigateParamContainer
{
  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get editorHeight(): number {
    return this.M.editorHeight != null ? this.M.editorHeight : 0.0;
  }

  get editorParams(): IModel {
    return this.M.editorParams;
  }

  get editorStyle(): string {
    return this.M.editorStyle;
  }

  get editorType(): string {
    return this.M.editorType;
  }

  get editorWidth(): number {
    return this.M.editorWidth != null ? this.M.editorWidth : 0.0;
  }

  get objectIdField(): string {
    return this.M.objectIdField;
  }

  get objectNameField(): string {
    return this.M.objectNameField;
  }

  get objectValueField(): string {
    return this.M.objectValueField;
  }

  protected pseditoritems: IPSEditorItem[];
  getPSEditorItems(): IPSEditorItem[] | null {
    return (
      this.pseditoritems ||
      (this.pseditoritems = this.fillChildListModel(
        this.M.getPSEditorItems,
        S._3de,
      ) as IPSEditorItem[])
    );
  }

  findPSEditorItem(objKey: any): IPSEditorItem | null {
    return this.getPSModel5(
      S._3de,
      this.getPSEditorItems(),
      objKey,
    ) as IPSEditorItem;
  }

  protected psnavigatecontexts: IPSNavigateContext[];
  getPSNavigateContexts(): IPSNavigateContext[] | null {
    return (
      this.psnavigatecontexts ||
      (this.psnavigatecontexts = this.fillChildListModel(
        this.M.getPSNavigateContexts,
        S._8c,
      ) as IPSNavigateContext[])
    );
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5(
      S._8c,
      this.getPSNavigateContexts(),
      objKey,
    ) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[];
  getPSNavigateParams(): IPSNavigateParam[] | null {
    return (
      this.psnavigateparams ||
      (this.psnavigateparams = this.fillChildListModel(
        this.M.getPSNavigateParams,
        S._8a,
      ) as IPSNavigateParam[])
    );
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5(
      S._8a,
      this.getPSNavigateParams(),
      objKey,
    ) as IPSNavigateParam;
  }

  protected pssyscss: IPSSysCss;
  getPSSysCss(): IPSSysCss | null {
    return (
      this.pssyscss ||
      (this.pssyscss = this.fillObjectModel(
        S._278,
        this.M.getPSSysCss,
        S._2ac,
      ) as IPSSysCss)
    );
  }

  protected pssysdictcat: IPSSysDictCat;
  getPSSysDictCat(): IPSSysDictCat | null {
    return (
      this.pssysdictcat ||
      (this.pssysdictcat = this.fillObjectModel(
        S._279,
        this.M.getPSSysDictCat,
        S._315,
      ) as IPSSysDictCat)
    );
  }

  protected pssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.pssyspfplugin ||
      (this.pssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get placeHolder(): string {
    return this.M.placeHolder;
  }

  get predefinedType(): string {
    return this.M.predefinedType;
  }

  get textSeparator(): string {
    return this.M.textSeparator;
  }

  get valueSeparator(): string {
    return this.M.valueSeparator;
  }

  get valueType():
    | 'SIMPLE'
    | 'SIMPLES'
    | 'OBJECT'
    | 'OBJECTS'
    | 'USER'
    | 'USER2' {
    return this.M.valueType || 'SIMPLE';
  }

  get disabled(): boolean {
    return this.M.disabled != null ? this.M.disabled : false;
  }

  get editable(): boolean {
    return this.M.editable != null ? this.M.editable : true;
  }

  get readOnly(): boolean {
    return this.M.readOnly != null ? this.M.readOnly : false;
  }
  get cls(): string {
    return 'PSEditorImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._12e || cls == S._7) return true;
    return super.instanceof(cls);
  }
}
